package com.lmt_10;

import com.lmt_5.Student;

import java.util.*;

public class SetTest {
    public static void main(String[] args) {
        Set<Integer> set = new HashSet<>(); // 数据无序
        set.add(123);
        set.add(123);
        set.add(123);
        set.add(235);
        set.add(258);
        System.out.println(set);

        Set<Integer>set1 = new LinkedHashSet<>(); // 有序，不重复，五索引
        set1.add(122);
        set1.add(122);
        set1.add(123);
        set1.add(1233);
        set1.add(45);
        System.out.println(set1);


        Set<Integer> set2 = new TreeSet<>();
        set2.add(123);
        set2.add(123);
        set2.add(345);
        set2.add(456);

        System.out.println(set2);
        Set<com.lmt_5.Student > students = new TreeSet<>(( o1,  o2)-> o1.getAge() - o2.getAge());
        students.add(new Student("zs",12));
        students.add(new Student("lm",45));
        students.add(new Student("lo",78));
        System.out.println(students);
    }

}
